LG.resourcecreate = function (success)
{
    $(document).bind('keydown.resourcecreate', function (e)
    {
        if (e.keyCode == 13)
        {
            doAddFavorite();
        }
    });

    if (!window.resourcecreateWin)
    {
        var resourcecreatePanle = $("<form></form>");

        var resourcecreateTree = {
           
            url: 'sys/resource!create.shtml',
            checkbox: false,
            nodeWidth: 170
        };

        resourcecreatePanle.ligerForm({
            fields: [
                 { name:'resourceLevel', type: 'hidden',value:'1'},
                 { display: '菜单名称', name: 'resourceName', type: 'text', validate: { maxlength: 50, required: true, messages: { required: '请输入菜单名称'}} },
                 { display: "菜单图片", name: "resourceIcon",readOnly:true,  type: 'text',event:{name:'onfocus',value:'thisid ="resourceIcon" ;f_openIconsWin();'}}
                  ]
        });

        //验证
        jQuery.metadata.setType("attr", "validate");
      
        LG.validate(resourcecreatePanle);

        window.resourcecreateWin = $.ligerDialog.open({
           width: 350,
            height: 140, top: 200,
            isResize: true,
            title: '创建菜单',
            target: resourcecreatePanle,
            buttons: [
            { text: '确定', onclick: function ()
            {
                doAddFavorite();
            }
            },
            { text: '取消', onclick: function ()
            {
                window.resourcecreateWin.hide();
                $(document).unbind('keydown.resourcecreate');
            }
            }
            ]
        });
    }
    else
    {
        window.resourcecreateWin.show();
    }

    function doAddFavorite()
    { 
       var ResourceLevel = $("#resourceLevel").val();
       var ResourceName = $("#resourceName").val();
       var ResourceIcon = $("#resourceIcon").val();
       
        if (resourcecreatePanle.valid())
        { 
            LG.ajax({
                url:'sys/resource!create.shtml',
                data: { resourceLevel: ResourceLevel, resourceName:ResourceName,resourceIcon:ResourceIcon },
                success: function ()
                {
                    LG.showSuccess('创建成功');
                   
                    window.resourcecreateWin.hide();
                   // window.resourcecreateWin.close();
                    $(document).unbind('keydown.resourcecreate');
                  
                   treeSelect();
                    if (success)
                    {
                        success();
                    }
                },
                error: function (message)
                {
                    LG.showError(message);
                }
            });
        }

    }

};